/**
 * Created by zhaoxi on 2017/12/4.
 */
import React from "react";

import { Router, Route, Switch } from "react-router-dom";

import { getAsyncInjectors } from "../flow/asyncInjectors";

import { asyncComponent,
  //  asyncComponentModel
   } from "../flow/asyncComponent";

import history from "./history";

import * as locations from "./../const/locations";
import EnterScreen from "./../screen/EnterScreen";

export default function createRoutes(store) {
  // const { injectModel } = getAsyncInjectors(store);

  // const asyncModel = asyncComponentModel(injectModel);
  // const asyncModels = asyncComponentModels(injectModel);
  const MainScreen = asyncComponent(() => import("../screen/MainScreen"));

  const Home = asyncComponent(
    () => import("../screen/HoScreen"),
  );
  const Attendance = asyncComponent(() =>
  import("../screen/AttendanceScreen")
);
const Ranking = asyncComponent(() =>
  import("../screen/RankScreen")
);
  const ForgotPwdScreen = asyncComponent(() =>
    import("../screen/ForgotPwdScreen")
  );
  const LoginScreen = asyncComponent(() => import("../screen/LoginScreen"));
  const RegisterScreen = asyncComponent(() =>
    import("../screen/RegisterScreen")
  );
  const TypeSelectScreen = asyncComponent(() =>
    import("../screen/TypeSelectScreen")
  );

  const TASKDETAIL = asyncComponent(() => import("../screen/task/TaskScreen"));
  const ADDCUIJI = asyncComponent(() => import("../screen/task/AddCuiji"));
  const CUIJIDETAIL = asyncComponent(() => import("../screen/task/CuijiScreen"));
  const DEBTINFO = asyncComponent(() => import("../screen/task/DebtScreen"));
  const CASEINFO = asyncComponent(() => import("../screen/task/CaseScreen"));
  const HANDS = asyncComponent(() => import("../screen/task/HandsScreen"));
  const PUTOFF = asyncComponent(() => import("../screen/task/PutOffScreen"));
  const REPAYLIST = asyncComponent(() => import("../screen/task/RepayListScreen"));

  const STAT = asyncComponent(() => import("../screen/attend/StatScreen"));
  const CALENDAR = asyncComponent(() => import("../screen/attend/CalendarScreen"));
  const LEAVE = asyncComponent(() => import("../screen/attend/LeaveScreen"));
  const RECARD = asyncComponent(() => import("../screen/attend/RecardScreen"));
  const APPLY = asyncComponent(() => import("../screen/attend/ApplyRecordsScreen"));
  const APPLY_DETAIL = asyncComponent(() => import("../screen/attend/ApplyDetailScreen"));
  const ADD_DAILY = asyncComponent(() => import("../screen/attend/AddDailyScreen"));
  const DAILY = asyncComponent(() => import("../screen/attend/DailyScreen"));
  const ME = asyncComponent(() => import("../screen/MyScreen"));
  const HL = asyncComponent(() => import("../screen/mine/Help"));
  const US = asyncComponent(() => import("../screen/mine/AboutUs"));
  const DAILY_M = asyncComponent(() => import("../screen/mine/DailyManageScreen"));
  const CUIJI_M = asyncComponent(() => import("../screen/mine/CuijiManageScreen"));
  const MY_BONUS = asyncComponent(() => import("../screen/mine/MyBonusScreen"));
  const KEFU =  asyncComponent(() => import("../screen/mine/ServiceScreen"));
  const SET =  asyncComponent(() => import("../screen/mine/SetScreen"));
  const ChangePwdScreen = asyncComponent(() => import("../screen/ChangePwdScreen"));
  const PROBLEM = asyncComponent(() => import("../screen/mine/Problem"));
  const ErrorScreen = asyncComponent(() => import("../screen/ErrorScreen"));
  const NOTFOUND = asyncComponent(() => import("../screen/404"));
  const NEWS = asyncComponent(() => import("../screen/mine/News"));
  const TaskNews = asyncComponent(() => import("../screen/mine/NewsTask"));
  const NoticeContent = asyncComponent(() => import("../screen/mine/NoticeDetail"));
  const NewsContent = asyncComponent(() => import("../screen/mine/NewsTaskDetail"));
  const SKILLDETAIL = asyncComponent(() => import("../screen/mine/SkillDetail"));
  
  class Routes extends React.Component {
    render() {
      return (
        <Router history={history}>
          <Switch>
          <Route exact path={locations.ENTER} component={EnterScreen} />
            <Route
              path={locations.MAIN}
              render={() => {
                return (
                  <MainScreen>

                    {/* <Route exact path={locations.MAIN} component={ADDCUIJI} /> */}
                    <Route exact path={locations.MAIN} component={Home} />
                   
                    <Route path={locations.ATTENDANCE} component={Attendance} />
                    <Route path={locations.RANKING} component={Ranking} />
                    <Route path={locations.ME} component={ME} />
                  </MainScreen>
                );
              }}
            />
            <Route path={locations.LOGIN} component={LoginScreen} />
            <Route path={locations.REGISTER} component={RegisterScreen} />
            <Route path={locations.FORGOTPWD} component={ForgotPwdScreen} />
            
            <Route path={locations.TASKDETAIL} component={TASKDETAIL} />
            <Route path={locations.ADDCUIJI} component={ADDCUIJI} />
            <Route path={locations.CUIJIDETAIL} component={CUIJIDETAIL} />
            <Route path={locations.DEBTINFO} component={DEBTINFO} />
            <Route path={locations.CASEINFO} component={CASEINFO} />
            <Route path={locations.HANDS} component={HANDS} />
            <Route path={locations.PUTOFF} component={PUTOFF} />
            <Route path={locations.REPAYLIST} component={REPAYLIST} />

            <Route path={locations.STAT} component={STAT} />
            <Route path={locations.CALENDAR} component={CALENDAR} />
            <Route path={locations.LEAVE} component={LEAVE} />
            <Route path={locations.RECARD} component={RECARD} />
            <Route path={locations.APPLY} component={APPLY} />
            <Route path={locations.APPLY_DETAIL} component={APPLY_DETAIL} />
            <Route path={locations.ADD_DAILY} component={ADD_DAILY} />
            <Route path={locations.DAILY} component={DAILY} />
            
            <Route path={locations.TYPE_SELECT} component={TypeSelectScreen} />
            <Route path={locations.NEWS} component={NEWS} />
            <Route path={locations.TaskNews} component={TaskNews} />
            <Route path={locations.NoticeContent} component={NoticeContent} />
            <Route path={locations.NewsTaskDetail} component={NewsContent} />
            <Route path={locations.SKILLDETAIL} component={SKILLDETAIL} />
            
            <Route path={locations.HL} component={HL} />
            <Route path={locations.US} component={US} />
            <Route path={locations.SET} component={SET} />
            <Route path={locations.DAILY_M} component={DAILY_M} />
            <Route path={locations.CUIJI_M} component={CUIJI_M} />
            <Route path={locations.MY_BONUS} component={MY_BONUS} />
            <Route path={locations.KEFU} component={KEFU} />
            <Route path={locations.CHANGEPWD} component={ChangePwdScreen} />
            <Route path={locations.PROBLEM} component={PROBLEM} />
            <Route path={locations.ERROR} component={ErrorScreen} />
            <Route path="*" component={NOTFOUND} />
          </Switch>
        </Router>
      );
    }
  }

  return Routes;
}
